package pers.cz.javacvdemo.oss.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.time.ZonedDateTime;
import java.util.List;
import java.util.Map;

/**
 * @version 1.0
 * @description: 映射到redis的事件记录
 * @author: ChengZhi 0336
 * @create: 2025-08-14 12:10
 **/
@Data
public class EventRecord {

	@JsonProperty("Records")
	private List<Record> records;

	@Data
	public static class Record {
		private String eventVersion;
		private String eventSource;
		private String awsRegion;
		private ZonedDateTime eventTime;
		private String eventName;
		private UserIdentity userIdentity;
		private RequestParameters requestParameters;
		private ResponseElements responseElements;
		private S3 s3;
		private Source source;
	}

	@Data
	public static class UserIdentity {
		private String principalId;
	}

	@Data
	public static class RequestParameters {
		private String principalId;
		private String region;
		private String sourceIPAddress;
	}

	@Data
	public static class ResponseElements {
		@JsonProperty("x-amz-id-2")
		private String x_amz_id_2;

		@JsonProperty("x-amz-request-id")
		private String x_amz_request_id;

		@JsonProperty("x-minio-deployment-id")
		private String x_minio_deployment_id;

		@JsonProperty("x-minio-origin-endpoint")
		private String x_minio_origin_endpoint;
	}

	@Data
	public static class S3 {
		private String s3SchemaVersion;
		private String configurationId;
		private Bucket bucket;
		private Object object;

		@Data
		public static class Bucket {
			private String name;
			private OwnerIdentity ownerIdentity;
			private String arn;

			@Data
			public static class OwnerIdentity {
				private String principalId;
			}
		}

		@Data
		public static class Object {
			private String key;
			private Long size;
			private String eTag;
			private String sequencer;
			private String contentType;
			private Map<String, String> userMetadata;
		}
	}

	@Data
	public static class Source {
		private String host;
		private String port;
		private String userAgent;
	}
}
